<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 总持续时间可被 60 整除的歌曲 -->
    <script>
      var numPairsDivisibleBy60 = function (time) {
        // % 60 map
        let m = new Map()
        let res = 0
        for (let t of time) {
          let cur = t % 60
          let tar = (60 - cur) % 60
          if (m.has(tar)) res += m.get(tar)
          if (!m.has(cur)) m.set(cur, 1)
          else m.set(cur, m.get(cur) + 1)
        }
        return res
      }
      console.log(numPairsDivisibleBy60([30, 20, 150, 100, 40]))
    </script>
  </body>
</html>
